class User
  include Mongoid::Document

  @desc = '用户'

  def_field :username, type: String, desc: '用户名'
  def_field :name, type: String, desc: '姓名'
  def_field :age, type: Integer, desc: '年龄'

  has_many :posts

  validates :username, presence: true, uniqueness: true
end
